/**
 * 
 */
package com.dingjian.meal.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.dingjian.base.CoreEntity;
import com.dingjian.base.service.BaseService;
import com.dingjian.base.util.StringUtils;
import com.dingjian.framework.base.controller.ListController;
import com.dingjian.meal.model.MealTime;
import com.dingjian.meal.service.MealTimeService;

/**
 *
 * @author FengMy
 * @since 2012-6-8
 */
@Controller
@RequestMapping(value="meal/mealTime/*")
public class MealTimeListController extends ListController {
	@Resource(name="mealTimeService")
	private MealTimeService mealTimeService;
	
	@RequestMapping(value="enable")
	public void enable(HttpServletResponse response){
		String id = getString("id");
		MealTime mealTime = mealTimeService.getEntityById(id);
		mealTime.setEnable("1".equals(getString("enable")));
		mealTimeService.updateEntity(mealTime);
	}

	@Override
	protected CoreEntity createNewEntity() {
		MealTime mealTime = new MealTime();
		mealTime.setDate(new Date());
		return mealTime;
	}

	@Override
	protected String getListView() {
		return "meal/mealTimeList";
	}

	@Override
	protected String getEditView() {
		return "meal/mealTimeEdit";
	}

	@Override
	protected String getListMapper() {
		return "com.dingjian.meal.dao.MealTimeDao.select";
	}

	@Override
	protected BaseService<MealTime> getService() {
		return mealTimeService;
	}
}
